<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page language="java" import="java.util.*" %>
<%@  page import   =   "java.text.*"   %>
<%@  page import   =   "java.sql.*"   %>
<%
String context = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+context+"/";
List list=(List)request.getAttribute("list");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <script src="<%=request.getContextPath()%>/js/ajax1.js" language="javascript"></script>
  <script src="<%=request.getContextPath()%>/js/mootools-1.2.1-core-yc.js" language="javascript"></script>
  <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="<%= context%>/js/lib/prototype.js"></script>
    <script type="text/javascript" src="<%= context%>/js/lib/autocomplete.js"></script>
    <link rel="stylesheet" type="text/css" href="<%= context%>/css/autocomplete/autocomplete.css" /> 
    
    <script language="javascript">
        var guid="";
        function MM(){
            var url="<%= request.getContextPath()%>/Chaxun";
            var myAjax = new Ajax1(url,{method:'POST',onComplete:function(){
                 var a=this.req.responseText;
                 var xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); 
                 xmlDoc.loadXML(a);
                 x=xmlDoc.documentElement.childNodes;
                 if(x!=null&&x.length>0){
                     var table_str="<table border='1'><tr><th>rec_guid</th><th>ani</th><th>dnis</th></tr>";
                     for (i=0;i<x.length;i++){
                         var rec_guid=xmlDoc.getElementsByTagName("rec_guid")[i].childNodes[0].nodeValue;
                         rec_guid=rec_guid.replace(/\ +/g,"");
                         rec_guid=rec_guid.replace(/[ ]/g,"");    
                         rec_guid=rec_guid.replace(/[\r\n]/g,"");
                         var rec_guid1="'"+rec_guid+"'";
                         var ani=xmlDoc.getElementsByTagName("ani")[i].childNodes[0].nodeValue;
                         var dnis=xmlDoc.getElementsByTagName("dnis")[i].childNodes[0].nodeValue; 
                         table_str=table_str+'<tr onclick="getguid('+rec_guid1+')"><td>'+rec_guid+'</td><td>'+ani+'</td><td>'+dnis+'</td></tr>';
                     } 
                     table_str=table_str+"</table>";
                 }
                 document.getElementById("test").innerHTML=table_str;   
                              
            }});       
        }
        
        function MM1(){
            var url="<%= request.getContextPath()%>/queryrec?rec_guid="+guid;
            var myAjax = new Ajax1(url,{method:'POST',onComplete:function(){
                 var a=this.req.responseText;
                 alert(a);                       
            }});  
        }
        function getguid(a){
           var form = document.forms[0];    
           form.method = 'post';    
           form.action = '<%= request.getContextPath()%>/GetRecord?rec_guid='+a;
           form.submit();  
        }
    </script>
  </head>
  
  <body>
  
<form id="form1" action = "sava.jsp/save.action" target="hidden_frame">
<table height="80%" width="80%"  border='1'>
<tr height="10%" width="10%"><th>主叫</th><th>被叫</th><th>录音开始时间</th><th>录音结束时间</th><th>播放</th></tr>
<%
   if(list!=null&&list.size()>0){
	   SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	   for(int i=0;i<list.size();i++){
		   Map map=(Map)list.get(i);
		   String rec_guid=(String)map.get("record_guid");
		   String ani=(String)map.get("ani");
		   String dnis=(String)map.get("dnis");
		   
		   Timestamp starttime1=(Timestamp)map.get("starttime");
   		   String starttime=df.format(starttime1);
   		   
   		   Timestamp endtime1=(Timestamp)map.get("endtime");
		   String endtime=df.format(endtime1);
		   %>
		   <tr><td><%=ani %></td><td><%=dnis %></td><td><%=starttime%></td><td><%=endtime%></td><td><input type="button" value="播放" onclick="getguid('<%=rec_guid%>')"/></td></tr>
		   
		   <% 
		   
	   }
   }else{
	   %>
	      <tr ><td>没有数据</td><td>没有数据</td><td>没有数据</td><td>没有数据</td><td>没有数据</td></tr>
	   <% 
   }

%>
</table>
</form>
<iframe name='hidden_frame' id="hidden_frame" style="display:none"></iframe>
  </body>
</html>
